clear all
set more off
capture log close
log using "$output/figure7.log", replace

version 16	

use "$data/acsmergeddata.dta", clear

sum newrtwchange if calckids>0 [aw=perwt]
bysort married: sum newrtwchange if calckids>0 [aw=perwt]

sum newrtwchange if calckids>0 & sex==2 & agi<80000 & incwage>0 [aw=perwt]
bysort married: sum newrtwchange if calckids>0 & sex==2 & agi<80000 & incwage>0 [aw=perwt]

sum newrtwchange if calckids>0 & sex==2 & agi<40000 & incwage>0 [aw=perwt]
bysort married: sum newrtwchange if calckids>0 & sex==2 & agi<40000 & incwage>0 [aw=perwt]

replace newrtwchange=max(-20,-100*newrtwchange)

twoway hist newrtwchange [fw=perwt] if calckids>0 & married, color(gs6) w(1) frac ||  hist newrtwchange [fw=perwt] if calckids>0 & married==0, w(1) frac fcolor(none) lcolor(black) graphregion(color(white)) bgcolor(white) ytitle("Fraction of Sample") text(.3 -10 "Average = -4.1%" "Married Average = -2.6%" "Unmarried Average = -6.4%" , j(left) size(medsmall)) xtitle("Change in Return to Work (Pct Pts)" "{bf:Panel A: All Parents}") xlabel(0(-4)-20) ylabel(0(.1).35) leg(order(1 "Married" 2 "Unmarried") c(1) pos(11) ring(0))
graph save "$output/newrtwchangechangehist1.gph", replace

twoway hist newrtwchange [fw=perwt] if calckids>0 & married & agi<80000 & incwage>0, color(gs6) w(1) frac ||  hist newrtwchange [fw=perwt] if calckids>0 & married==0 & agi<80000 & incwage>0, w(1) frac fcolor(none) lcolor(black) graphregion(color(white)) bgcolor(white) ytitle("Fraction of Sample") text(.3 -10 "Average = -5.5%" "Married Average = -2.9%" "Unmarried Average = -8.7%" , j(left) size(medsmall)) xtitle("Change in Return to Work (Pct Pts)" "{bf:Panel B: Working with AGI < $80,000}") xlabel(0(-4)-20) ylabel(0(.1).35) leg(order(1 "Married" 2 "Unmarried") c(1) pos(11) ring(0))
graph save "$output/newrtwchangechangehist2.gph", replace

twoway hist newrtwchange [fw=perwt] if calckids>0 & married & agi<40000 & incwage>0, color(gs6) w(1) frac ||  hist newrtwchange [fw=perwt] if calckids>0 & married==0 & agi<40000 & incwage>0, w(1) frac fcolor(none) lcolor(black) graphregion(color(white)) bgcolor(white) ytitle("Fraction of Sample") text(.3 -10 "Average = -5.6%" "Married Average = -2.8%" "Unmarried Average = -9.6%" , j(left) size(medsmall)) xtitle("Change in Return to Work (Pct Pts)" "{bf:Panel C: Working with AGI < $40,000}") xlabel(0(-4)-20) ylabel(0(.1).35) leg(order(1 "Married" 2 "Unmarried") c(1) pos(11) ring(0))
graph save "$output/newrtwchangechangehist3.gph", replace

graph combine "$output/newrtwchangechangehist1.gph" "$output/newrtwchangechangehist2.gph" "$output/newrtwchangechangehist3.gph", col(1) graphregion(color(white))
graph export "$output/figure7.png", replace

erase "$output/newrtwchangechangehist1.gph"
erase "$output/newrtwchangechangehist2.gph"
erase "$output/newrtwchangechangehist3.gph"

log close